import Vue from 'vue'
import Router from 'vue-router'

import index from '../views/index/index'
import Home from '../views/index/home/home'

import Login from '../views/index/login/login' // 登陆页

const System = () => import('../views/index/system/system') // 系统管理

const ParamManage = () => import('../views/index/collection/paramManage') // 参数管理
const Investigation = () => import('../views/index/investigation/survey') // 林区样线调查
const Intelligence = () => import('../views/index/Intelligence/weather/index') // 物联网智能感知
const Geography = () => import('../views/index/geography/index') // 地理信息

const BigData = () => import('../views/index/bigData/index') // 大数据
const surveyMap = () => import('../views/index/investigation/surveyMap') // 大数据
const surveyData = () => import('../views/index/investigation/surveyData')
const Distinguish = () => import('../views/index/distinguish/distinguish') // 动物识别
// 引入动物识别二级路由
const DistinguishView = () => import('../views/index/distinguish/distinguishView')
const DistinguishData = () => import('../views/index/distinguish/distinguishData')
const geographyData = () => import('../views/index/geography/geoData')
const geographyView = () => import('../views/index/geography/geoMap')

const Surveillance = () => import('../views/index/Intelligence/video/index') // 视频监控

const MeteorologicalView = () => import('../views/index/Intelligence/weather/MeteorologicalView') // 气象展示
const MeteorologicalData = () => import('../views/index/Intelligence/weather/MeteorologicalData') // 气象列表
const MeteorologicalHistory = () => import('../views/index/Intelligence/weather/MeteorologicalHistory') // 气象历史

const SurveillanceView = () => import('../views/index/Intelligence/video/videoView') // 监控视图
const SurveillanceData = () => import('../views/index/Intelligence/video/videoData') // 数据列表

// 引入系统管理二级路由
const User = () => import('../views/index/system/components/user') //  人员
const Department = () => import('../views/index/system/components/department') //  部门
const Role = () => import('../views/index/system/components/role') //   角色
const Menu = () => import('../views/index/system/components/menu') //   菜单

const Resource = () => import('../views/index/resource/resource') // 资源管理
const SurveyManage = () => import('../views/index/resource/surveyManage') // 调查数据管理
const Code = () => import('../views/index/resource/code') // 二维码详情

const SpeciesManage = () => import('../views/index/resource/speciesManage') // 物种管理

const LibraryManage = () => import('../views/index/resource/manage') // 库信息
const ProdManage = () => import('../views/index/resource/prod/prodManage') // 生产管理
const Evaluate = () => import('../views/index/resource/evaluate') // 测定评价管理
const PreserveSave = () => import('../views/index/resource/preserveSave') // 种质保存登记
const GatherRegister = () => import('../views/index/resource/gatherRegister') // 野外采集登记

const Classify = () => import('../views/index/resource/classify/index') // 资源分类
const Template = () => import('../views/index/resource/classify/template') // 采集模板
const TemplateGroup = () => import('../views/index/resource/classify/templateGroup') // 采集组
const TemplateItem = () => import('../views/index/resource/classify/templateItem') // 采集项

const SeedlingBreeding = () => import('../views/index/resource/seedlingBreeding')
const SeedlingSizes = () => import('../views/index/resource/seedlingSizes')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: index,
      redirect: '/login',
      children: [
        {path: 'home', name: 'home', component: Home, meta: {showHeader: false, index: 0}},
        {path: 'login', name: 'login', component: Login},
        {
          path: 'geography',
          name: 'geography',
          component: Geography,
          redirect: '/geography/geographyView',
          meta: {showHeader: true, index: 1},
          children: [
            {
              path: 'geographyData',
              name: 'geographyData',
              component: geographyData,
              props: true,
              meta: {showHeader: true, index: 1, clickIndex: 1, selectionIndex: 1}
            },
            {
              path: 'geographyView',
              name: 'geographyView',
              component: geographyView,
              props: true,
              meta: {showHeader: true, index: 1, clickIndex: 0, selectionIndex: 0}
            }
          ]
        },
        {path: 'bigData', name: 'bigData', component: BigData, meta: {showHeader: false, index: 2}},
        {
          path: 'resource',
          name: 'resource',
          component: Resource,
          redirect: '/resource/speciesManage',
          meta: {showHeader: true, index: 0},
          children: [
            {
              path: 'speciesManage',
              name: 'speciesManage',
              component: SpeciesManage,
              meta: {showHeader: true, index: 0, clickIndex: 0}
            },
            {
              path: 'manage',
              name: 'manage',
              component: LibraryManage,
              props: true,
              meta: {showHeader: true, index: 1}
            },
            {
              path: 'prodManage',
              name: 'prodManage',
              component: ProdManage,
              props: true,
              meta: {showHeader: true, index: 1}
            },
            {path: 'surveyManage', name: 'surveyManage', component: SurveyManage, meta: {showHeader: true, index: 2}},
            {path: 'preserveSave', name: 'preserveSave', component: PreserveSave, meta: {showHeader: true, index: 3}},
            {path: 'gatherRegister', name: 'gatherRegister', component: GatherRegister, meta: {showHeader: true, index: 4}},
            {path: 'evaluate', name: 'evaluate', component: Evaluate, meta: {showHeader: true, index: 3, clickIndex: 5}},
            {
              path: 'classify',
              name: 'classify',
              component: Classify,
              props: true,
              redirect: '/resource/classify/template',
              meta: {showHeader: true, index: 6},
              children: [
                {
                  path: 'template',
                  name: '采集模板',
                  component: Template,
                  props: true,
                  meta: {showHeader: true, index: 6, clickIndex: 0}
                },
                {
                  path: 'templateGroup',
                  name: '采集组',
                  component: TemplateGroup,
                  props: true,
                  meta: {showHeader: true, index: 6, clickIndex: 1}
                },
                {
                  path: 'templateItem',
                  name: '采集项',
                  component: TemplateItem,
                  props: true,
                  meta: {showHeader: true, index: 6, clickIndex: 2}
                }
              ]
            },
            {path: 'seedlingBreeding', name: 'seedlingBreeding', component: SeedlingBreeding, meta: {showHeader: true, index: 7}},
            {path: 'seedlingSizes', name: 'seedlingSizes', component: SeedlingSizes, meta: {showHeader: true, index: 8}},
          ]
        },

        {path: 'code', name: 'code', component: Code, meta: {showHeader: false, index: 3}},
        {path: 'paramManage', name: 'paramManage', component: ParamManage, meta: {showHeader: true, index: 5}},
        {
          path: 'investigation',
          name: 'investigation',
          component: Investigation,
          redirect: '/investigation/surveyMap',
          meta: {showHeader: true, index: 7},
          children: [
            {
              path: 'surveyMap',
              name: 'surveyMap',
              component: surveyMap,
              props: true,
              meta: {showHeader: true, index: 7, clickIndex: 0}
            },
            {
              path: 'surveyData',
              name: 'surveyData',
              component: surveyData,
              props: true,
              meta: {showHeader: true, index: 7, clickIndex: 1}
            }
          ]
        },
        {
          path: 'intelligence',
          name: 'intelligence',
          component: Intelligence,
          redirect: '/intelligence/meteorologicalView',
          meta: {showHeader: true, index: 8},
          children: [
            {
              path: 'meteorologicalView',
              name: '数据展示',
              component: MeteorologicalView,
              props: true,
              meta: {showHeader: true, index: 8, clickIndex: 0}
            },
            {
              path: 'meteorologicalData',
              name: '数据列表',
              component: MeteorologicalData,
              props: true,
              meta: {showHeader: true, index: 8, clickIndex: 1}
            },
            {
              path: 'meteorologicalHistory',
              name: '历史数据',
              component: MeteorologicalHistory,
              props: true,
              meta: {showHeader: true, index: 8, clickIndex: 2}
            }
          ]
        },
        {
          path: 'surveillance',
          name: '视频监控',
          component: Surveillance,
          redirect: '/surveillance/video',
          meta: {showHeader: true, index: 8, clickIndex: 0},
          children: [
            {
              path: 'video',
              name: '监控视图',
              component: SurveillanceView,
              meta: {showHeader: true, index: 8, clickIndex: 1}
            },
            {
              path: 'data',
              name: '数据列表',
              component: SurveillanceData,
              meta: {showHeader: true, index: 8, clickIndex: 2}
            }
          ]
        },
        {
          path: 'distinguish',
          name: 'distinguish',
          component: Distinguish,
          redirect: '/distinguish/distinguishView',
          meta: {showHeader: true, index: 9},
          children: [
            {
              path: 'distinguishView',
              name: 'distinguishView',
              component: DistinguishView,
              props: true,
              meta: {showHeader: true, index: 9, clickIndex: 0, selectionIndex: 0}
            },
            {
              path: 'distinguishData',
              name: 'distinguishData',
              component: DistinguishData,
              props: true,
              meta: {showHeader: true, index: 9, clickIndex: 1, selectionIndex: 1}
            }
          ]
        },
        {
          path: 'system',
          name: 'system',
          component: System,
          redirect: '/system/user',
          meta: {showHeader: true, index: 10},
          children: [
            {
              path: 'user',
              name: '人员',
              component: User,
              props: true,
              meta: {showHeader: true, index: 10, clickIndex: 0}
            },
            {
              path: 'department',
              name: '部门',
              component: Department,
              props: true,
              meta: {showHeader: true, index: 10, clickIndex: 1}
            },
            {
              path: 'role',
              name: '角色',
              component: Role,
              props: true,
              meta: {showHeader: true, index: 10, clickIndex: 2}
            },
            {
              path: 'menu',
              name: '菜单',
              component: Menu,
              props: true,
              meta: {showHeader: true, index: 10, clickIndex: 3}
            }
          ]
        }
      ]
    },
    { path: '*', redirect: '/home' }
  ]
})

const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
